import 'dart:convert';

// id	int	地址id
// mobile	int	用户服务联系电话
// sex	int	性别 1男 2女
// sex_words	string	性别文案 （先生/女士）
// contacts	string	地址联系人
// address	string	服务地址
// address_detail	string	服务详细地址
// lon	double	经度
// lat	double	纬度
// default_status	int	是否是默认地址 1：默认地址 2：不是
// data. adds_province	string	省
// data. adds_city	string	市
// data. adds_area	string	区 （无区 返回空字符串）


class AddressModel {
  final int? id;
  final String? mobile;
  final int? sex;
  final String? contacts;
  final String? address;
  final String? addressDetail;
  final double? lon;
  final double? lat;
  final int? defaultStatus;
  final String? addsProvince;
  final String? addsCity;
  final String? addsArea;
  final String? sexWords;

  AddressModel({
    this.id,
    this.mobile,
    this.sex,
    this.contacts,
    this.address,
    this.addressDetail,
    this.lon,
    this.lat,
    this.defaultStatus,
    this.addsProvince,
    this.addsCity,
    this.addsArea,
    this.sexWords,
  });

  factory AddressModel.fromJson(String str) => AddressModel.fromMap(json.decode(str));

  String toJson() => json.encode(toMap());

  factory AddressModel.fromMap(Map<String, dynamic> json) => AddressModel(
        id: json["id"],
        mobile: json["mobile"],
        sex: json["sex"],
        contacts: json["contacts"],
        address: json["address"],
        addressDetail: json["address_detail"],
        lon: json["lon"]?.toDouble(),
        lat: json["lat"]?.toDouble(),
        defaultStatus: json["default_status"],
        addsProvince: json["adds_province"],
        addsCity: json["adds_city"],
        addsArea: json["adds_area"],
        sexWords: json["sex_words"],
      );

  Map<String, dynamic> toMap() => {
        "id": id,
        "mobile": mobile,
        "sex": sex,
        "contacts": contacts,
        "address": address,
        "address_detail": addressDetail,
        "lon": lon,
        "lat": lat,
        "default_status": defaultStatus,
        "adds_province": addsProvince,
        "adds_city": addsCity,
        "adds_area": addsArea,
        "sex_words": sexWords,
      };
}
